﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DAL;
using DomainModel;

namespace DALTool
{
    class DALTool
    {

        /*
         *tool for  DALCustomer
         *
         */
        /*
        Deciding that test is right or not
            */
       
        public static void PassOrNot(int result, BaseCustomer getId)
        {
            List<string> errors = new List<string>();
            if (result == 1)
            {
                Assert.AreEqual(0, errors.Count);

            }
            else
            {

                Assert.AreEqual(1, errors.Count);

            }
            DalCustomers.DeleteCustomer(getId.customer_id, ref errors);

        }
        public static Customer insertDataToTable()
        {
            Customer customer = new Customer();
            List<string> errors = new List<string>();
            customer.email = "myemail@ucsd.edu";
            customer.first_name = "john";
            customer.last_name = " doe";
            customer.address = "123 hello street";
            customer.state = "ca";
            customer.zip = 92122;
            customer.city = "san diego";
            customer.webmaster = 0;
            customer.blockuser = 0;
            DalCustomers.InsertCustomer(customer, ref errors);
            return customer;
        }

        public static void MuinsertDataToTable()
        {
            Customer customer = new Customer();
            List<string> errors = new List<string>();
            customer.email = "youemail@ucsd.edu";
            customer.first_name = "who";
            customer.last_name = " am i";
            customer.address = "123 goodbye street";
            customer.state = "NY";
            customer.zip = 92122;
            customer.city = "Your city ";
            customer.webmaster = 0;
            customer.blockuser = 0;
            DalCustomers.InsertCustomer(customer, ref errors);

            customer.email = "your@ucsd.edu";
            customer.first_name = "bob";
            customer.last_name = " ma";
            customer.address = "123234 hello street";
            customer.state = "WA";
            customer.zip = 92122;
            customer.city = "My City";
            customer.webmaster = 0;
            customer.blockuser = 0;
            DalCustomers.InsertCustomer(customer, ref errors);

        }

        public static void UpdateDummyInfor(BaseCustomer customer)
        {
            customer.address = "test address";
            customer.state = "test state";
            customer.zip = 99999;
            customer.city = "test city";

        }

        public static int insertDummyOrder()
        {

            //customer.first_name = "john";
          //  customer.last_name = " doe";

            BaseCustomer DummyBaseCustomer = new BaseCustomer();
            List<string> errors = new List<string>();



            DummyBaseCustomer.first_name = "john"; 
            DummyBaseCustomer.last_name = " doe";

            BaseCustomer DummyId = DalCustomers.getId(DummyBaseCustomer, ref errors);
            int tempId = DummyId.customer_id;
            Order DumOrder = new Order();
            DumOrder.customer_id = tempId;
            DateTime days = DumOrder.date_created;
            DALOrders.InsertOrders(DumOrder, ref errors);
             Order temporder =  DALOrders.getOrderId(DumOrder, ref errors);
             int realordernumber = temporder.order_id;
             return realordernumber;
        }


        /*
            Item state = 0 : noting
         *             = 1 : stock
         *             = 2 : on order
         *             = 3 : speical order
         *             = 4 : commingsoon order
         *             
         * Pram: state : for testing state of Order in the demainModel.
         *      NiceToTA:  it will be order_id 
         */

        public static OrderItem insertDummyOrderItem(int state, int NiceToTA)
        {
            Order temporderid = new Order();

            OrderItem oi;
            if(state == 0)
            {
                oi = new OrderItem();
                oi.order_id = NiceToTA;
                oi.product_id = 1;
                oi.quantity = 2;
                
            }
            else if (state == 1) 
            {
             oi = new OrderItem();
             oi.order_id = NiceToTA;
                oi.product_id = 1;
                oi.quantity = 2;
   
            }
            else if (state == 2)
            {
                 oi = new OnOrderItem();
                 oi.order_id = NiceToTA;
                oi.product_id = 1;
                oi.quantity = 2;
//                oi.item_state = state;

            }
            else if (state == 3)
            {
                 oi = new SpeicalOrderItem();
                 oi.order_id = NiceToTA;
                oi.product_id = 1;
                oi.quantity = 2;

            }
            else if (state == 4)
            {
                 oi = new ComingSoonItem();
                 oi.order_id = NiceToTA;
                oi.product_id = 1;
                oi.quantity = 2;

            }
            else 
            {
                // can not be anything fucker!!
                return null;
            }


            return oi;

        }



        /*
         * Tool for
         */

    }
}
